function createAndVisualizeGraph(pathways)
    listOfPathways = evalin('base','listOfPathways');

    if isempty(pathways)
        return;
    end
    
    defines = evalin('base','defines');

    pathNodes = {};
    pathEdges=[];
    secondIndex = 1;
    lastNodesNames = [];

    index = 1;  
    for j=1:length(pathways(:, 1))
        pathway = listOfPathways{pathways(j,1)};
        for i = 1 : length(pathway(:, 1))
            if isempty(pathNodes)
                 pathNodes = [pathNodes; {pathway(i, :), index}];
            end    
            if ~ismember(pathway(i, :),pathNodes(:,1)) 
                 pathNodes = [pathNodes; {pathway(i, :), index}];
            end
            if i > 1
                mainIndex = find(strcmp(pathNodes(:,1),pathway(i, :)),1);
                mainIndexPr = find(strcmp(pathNodes(:,1),pathway(i-1, :)),1);

                if isempty(pathEdges)
                    pathEdges = [pathEdges; [mainIndexPr, mainIndex]];
                end

                isInList = false;
                for k = 1: length(pathEdges(:, 1))
                    if pathEdges(k,1) == mainIndexPr & pathEdges(k,2) == mainIndex
                        isInList = true;
                    end
                end

                if ~isInList
                    pathEdges = [pathEdges; [mainIndexPr, mainIndex]];
                end
            end
            index = index +1;
        end
        lastNodesNames = unique([lastNodesNames; pathway(i, :)],'rows'); 
    end
    
    if str2num(defines.isProductUsed) & str2num(defines.isSubstrateUsed)
       secondIndex = length(pathEdges);

       listOfPathways = evalin('base','prod_listOfPathways');
       index = 1;  
       for j=1:length(pathways(:, 1))
            pathway = listOfPathways{pathways(j,2)};
            for i = 1 : length(pathway(:, 1))
                if isempty(pathNodes)
                     pathNodes = [pathNodes; {pathway(i, :), index}];
                end    
                if ~ismember(pathway(i, :),pathNodes(:,1)) 
                     pathNodes = [pathNodes; {pathway(i, :), index}];
                end
                if i > 1
                    mainIndex = find(strcmp(pathNodes(:,1),pathway(i, :)),1);
                    mainIndexPr = find(strcmp(pathNodes(:,1),pathway(i-1, :)),1);

                    if isempty(pathEdges)
                        pathEdges = [pathEdges; [mainIndexPr, mainIndex]];
                    end

                    isInList = false;
                    for k = 1: length(pathEdges(:, 1))
                        if pathEdges(k,1) == mainIndexPr & pathEdges(k,2) == mainIndex
                            isInList = true;
                        end
                    end

                    if ~isInList
                        pathEdges = [pathEdges; [mainIndexPr, mainIndex]];
                    end
                end
                index = index +1;
            end
            lastNodesNames = unique([lastNodesNames; pathway(i, :)],'rows'); 
        end
    end
    

    p = [];
    for i = 1 : length(pathEdges(:,1)) * 2
        p = [p; 1];
    end

    sMatrix = sparse([pathEdges(:,2); pathEdges(:,1)], [pathEdges(:,1); pathEdges(:,2)], ...
        p, length(pathNodes(:,1)), length(pathNodes(:,1)));

    graphNodesNames = pathNodes(:,1);
    RxnsNodesIDs=[];
    MetsNodesIDs=[];
    LastNodesIDs=[];
    for i=1:length(pathNodes)
       if regexp(pathNodes{i}, 'R') == 1
           RxnsNodesIDs=[RxnsNodesIDs; i];
       elseif regexp(pathNodes{i}, 'C') == 1
           MetsNodesIDs=[MetsNodesIDs; i];
       end
       for j=1: length(lastNodesNames(:,1))
            if strcmp(pathNodes{i,1}, lastNodesNames(j, :))
                LastNodesIDs = [LastNodesIDs, i];
            end
       end

    end

    BGobj = biograph(sMatrix, graphNodesNames, 'LayoutType','equilibrium');
    set(BGobj.nodes(MetsNodesIDs),'Shape','ellipse'); 
    set(BGobj.nodes([1, secondIndex]),'Color',[255/255,0/255,0/255]);
    set(BGobj.nodes(RxnsNodesIDs),'Color',[241/255,176/255,102/255]);
    set(BGobj.nodes(LastNodesIDs),'Color',[180/255,186/255,182/255]);
    h=view(BGobj)

end